import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class testWorker {
    public static void main(String[] args) {
        List<Worker> list=new ArrayList<>();
        list.add(new Worker("zhang3",18,3000));
        list.add(new Worker("li4",25,3500));
        list.add(new Worker("wang5",22,3200));

        list.add(1,new Worker("zhao6",24,3400));

        list.remove(3);

        each2(list);
    }

    public static void each(List<Worker> list){
        for (int i=0;i< list.size();i++){
            Worker worker= list.get(i);
            System.out.println(worker);
        }
    }

    private static void each2(List<Worker> list){
        Iterator<Worker> it= list.iterator();
        while (it.hasNext()){
            Worker wo= it.next();
            wo.work();
        }
    }

}
